﻿using Microsoft.AspNetCore.Mvc.ApiExplorer;

namespace FastEasyAPI.Module.Swagger
{
    public class FastEasyRouteAttribute : RouteAttribute, IApiDescriptionGroupNameProvider
    {
        /// <summary>
        /// 默认的路由配置
        /// </summary>
        /// <param name="actionName"></param>
        public FastEasyRouteAttribute(string actionName) : base(actionName)
        {
        }

        /// <summary>
        /// 分组名称,控制不同版本:等同于配置ApiExplorerSettings(GroupName ="FastEasy")
        /// </summary>
        public string? GroupName { get; set; }

        /// <summary>
        /// 自定义的路由配置
        /// </summary>
        /// <param name="version"></param>
        /// <param name="actionName"></param>
        public FastEasyRouteAttribute(SwaggerVersion version, string actionName = "[action]") : base($"/{version.ToString()}/[controller]/{actionName}")
        {
            GroupName = version.ToString();
        }
    }
}